<template>
    <div>
      <el-dialog   width="70%" title="调度仓库商品" :visible.sync="dialogTableVisible">
        <el-table :data="WarehouseDetailsInfo">
          <el-table-column property="shopInfo.shopName" label="商品名称"></el-table-column>
          <el-table-column property="shopInfo.shopPrice" label="商品价格"></el-table-column>
          <el-table-column property="users.uname" label="供应商"></el-table-column>
          <el-table-column property="maxNum" label="最大值"></el-table-column>
          <el-table-column property="minNum" label="最小值"></el-table-column>
          <el-table-column property="amount" label="当前存储量"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button
                round
                type="primary"
                plain
                @click="Dispatching(scope.row)"
              >调度该商品</el-button>
            </template>
          </el-table-column>

        </el-table>
        <!-- 分页 -->
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageno"
          :page-sizes="[5, 10, 15, 20]"
          :page-size="pagesize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </el-dialog>
      <div>
        <component ref="Dispatching" is="Dispatching_goods"></component>
      </div>
    </div>
</template>

<script>
  import Dispatching_goods from "./Dispatching_goods";
    export default {
        name: "Dispatch_warehouse_goods",
      data(){
          return{
            dialogTableVisible:false,
            WarehouseDetails:{pId:""},
            WarehouseDetailsInfo:[],
            pageno: 1,
            pagesize: 5,
            total: 1,
          }
      },
      methods:{
        getDispatch_warehouse_goods() {
          var params = new URLSearchParams();
          params.append("pageno", this.pageno);
          params.append("pagesize", this.pagesize);
          params.append("pId", this.WarehouseDetails.pId)
          this.$axios.get("warehouseDetailsInfo/queryAllByPId.action", {params: params}).then(res => {
            this.WarehouseDetailsInfo = res.data.records;
            this.total = res.data.total;
          }).catch(error => {
            this.$message.error(error)
          })
        },
        handleSizeChange(val) {
          //每页范围
          this.pagesize = val;
          this.getDispatch_warehouse_goods();
        },
        handleCurrentChange(val) {
          //当前页
          this.pageno = val;
          this.getDispatch_warehouse_goods();
        },
        Dispatching(row){
          this.$refs.Dispatching.dialogTableVisible=true

          this.$nextTick(item=>{
            this.$refs.Dispatching.WarehouseDetails=row
            this.$refs.Dispatching.getdataWarehouseDetails()
            sessionStorage.setItem("Dispatching_goods_gname",row.shopInfo.shopName)
            sessionStorage.setItem("Dispatching_goods_amount",row.amount)
            sessionStorage.setItem("Dispatching_goods_id",row.id)
          })

        }
      },
      components:{
        Dispatching_goods
      }
    }
</script>

<style scoped>

</style>
